package com.ruoyi.project.sale.order.service;
/*1*/
import com.ruoyi.project.sale.order.domain.Order;
import com.ruoyi.project.sale.order.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public List<Order> findAll(Order order) {
        return orderMapper.selectAll(order);
    }

    @Override
    public Integer saveOrder(Order order) {
        return orderMapper.insertOrder(order);
    }

    @Override
    public Order findOne(Integer id) {
        return orderMapper.selectOne(id);
    }

    @Override
    public Integer changeOrder(Order order) {
        return orderMapper.updateOrder(order);
    }

    @Override
    public Integer removeOrder(Integer id) {
        return orderMapper.deleteOrder(id);
    }

    @Override
    public Integer removeOrders(Integer[] ids) {
        Integer index = orderMapper.deleteOrders(ids);//假如传入的是3条数据，返回值为3

        if (index==ids.length){
            return 1;  //返回1  用于判断成功的条件
        }
        return 0;
    }
}
